#pragma once
#include <list>
#include <mutex>

struct NetParam
{
	NetParam()
	{
		data = NULL;
	}
	~NetParam()
	{
		delete data;
	}
	void* user;
	int code;
	char* data;
	int size;
	char addr[64];
};

class Dispatcher
{
public:
	Dispatcher();
	virtual ~Dispatcher();

	void Update();

protected:

	void InvokeAsync(void(*func)(void* owner, void* param), void* owner, struct NetParam* param);

	void WakeAll(bool clear = false);

private:

	std::list<struct DispatcherAction*> funcList;
	std::mutex dispatchMux;

};

int64_t GetTimestamp();